package grpc

import (
	"google.golang.org/grpc"
	"google.golang.org/grpc/keepalive"
	"time"
)

var (
	defaultKeepAlive        = 30 * time.Second
	defaultKeepAliveTimeout = 10 * time.Second
)

type ClientOption struct {
	KeepAlive        time.Duration
	KeepAliveTimeout time.Duration
	ClientPoolSize   int
}

var defaultClientOption = &ClientOption{
	KeepAlive:        defaultKeepAlive,
	KeepAliveTimeout: defaultKeepAliveTimeout,
}

func GetClientDialOpts() []grpc.DialOption {
	return []grpc.DialOption{grpc.WithInsecure(),
		grpc.WithBlock(),
		grpc.WithKeepaliveParams(keepalive.ClientParameters{
			Time:    defaultClientOption.KeepAlive,
			Timeout: defaultClientOption.KeepAliveTimeout},
		)}
}
